<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>06_数组的join方法</title>
</head>

<body>
    <script>
        // join() : 用指定的字符串来连接数组中的元素,返回一个字符串,或者返回一个拼接好的字符串

        let nums = [33, 99, 66, 99, 888]
        //'33-99-66-99-888'
        console.log(nums.join('-'));
        //'33996699888'
        console.log(nums.join(''));
        console.log(nums); //原数组不改变


        //forEach()
        let arr1 = [0, 2, 4, 6, 8];
        let newArr1 = arr1.forEach(function (item, index, arr1) {
            console.log(this);
            console.log(arr1);
            arr1[index] = item / 2;
        }, this);
        console.log(arr1);
        console.log(newArr1);


        //  map()
        let arr = [0, 2, 4, 6, 8];
        let newArr = arr.map(function (item, index, arr) {
            console.log(this);
            console.log(arr);
            return item / 2;
        }, this);
        console.log(newArr);
    </script>
</body>

</html>